import 'package:get/get.dart';

enum SignStatus {
  ideal(-1, "空闲状态"),
  startUpload(0, "开始上传apk"),
  uploading(1, "正在上传"),
  uploaded(2, "上传完成"),
  uploadFail(3, "上传失败"),
  startSign(4, "开始签名apk"),
  signing(5, "签名中"),
  signFail(6, "签名失败"),
  signSuccess(7, "签名成功"),
  startDownload(8, "开始下载"),
  downloadSuccess(9, "下载成功");

  final int status;
  final String statusInfo;

  const SignStatus(this.status, this.statusInfo);
}

extension SignStatusX on SignStatus {
  bool get isIdeal => this == SignStatus.ideal;

  bool get isStartUpload => this == SignStatus.startUpload;

  bool get isUploading => this == SignStatus.uploading;

  bool get isUploaded => this == SignStatus.uploaded;

  bool get isStartSign => this == SignStatus.startSign;

  bool get isSignSuccess => this == SignStatus.signSuccess;

  bool get isSignFail => this == SignStatus.signFail;

  bool get isStartDownload => this == SignStatus.startDownload;

  bool get isDownloadSuccess => this == SignStatus.downloadSuccess;
}

class SignApkState {
  final SignStatus status;
  final double uploadProgress;

  SignApkState({this.status = SignStatus.ideal, this.uploadProgress = 0.0});

  SignApkState init() {
    return SignApkState(status: SignStatus.ideal);
  }

  SignApkState copyWith(SignStatus signStatus, {double uploadProgress = 0.0}) {
    printInfo(info: "signStatus ${signStatus.status} - ${uploadProgress}");
    return SignApkState(status: signStatus, uploadProgress: uploadProgress);
  }
}
